# 转移字符 '\'
# (1) 把普通的字符转化成特殊意义的字符
# (2) 把特殊的字符转化成普通意义的字符

# \n \t \r
# print("hello\nworld")
# print("hello\tworld")
# print("hello\rworld")
# print("D:\\python代码\2024.1.19")

# print("hello \"world\" ")

# 格式化输出
# (1)
# num = 18
# name = "zhangsan"
# print("我的名字是：%s,今年%d岁" % (name, num))
#
# num = 20
# name = "lisi"
# print("My name is %s,%d years old" % (name, num))

# (2) f-string结构
# age = 18
# name = "zhangsan"
# print(f"My name is {name} , {age} year old")
#
# age = 20
# name = "lisi"
# print(f"My name is {name} , {age} year old")

# 索引
# char = "hello world"
# print(char[0])
# print(char[-1])
# print(char[4])

# 切片
# char = "hello world"
# print(char[1:5])
# print(char[6:-1])
# print(char[6:])
# # 第一个省略为0，最后一个生省略为最后一个
# print(char)
# print(char[:])
# print(char[-5:-1])
# print(char[-5:])
# print(char[0::2])
# print(char[0::3])
# print(char[0::4])
# print(char[0::5])
# print(char[::-1])
# print(char[:-6:-1])

# len内置函数
# char = "hello world"
# num = len(char)
# print(num)
# print(len(char))

# in判断  一个字符串里面有没有另一个字符串
# char = "hello world"
# print("hello" in char)
# print("hel" in char)
# print(" hello" in char)

# +、*拼接
# char1 = "hello "
# char2 = "world "
# print(char1 + char2)
# char3 = "zhangsan"
# print(char1 + char2 + char3)

# num = int(input("Enter a number:"))
# char = "zhangsan "
# print(char * num)

# input
# num = int(input())
# print("hello" * num)

# char = input("Enter")
# print(char)
# input的返回值是字符（str）类型就可以了
# print("hellp", 42, 3.14)

# 内置字符函数
# lower and upper
# char = "hello world"
# char2 = "HELLO WORLD"
# print(char.upper()) # 大写
# print(char2.lower()) # 小写

# startswith and endswith
# char = "hello world"
# print(char.startswith("hello"))
# print(char.startswith("hel"))
# print(char.startswith(" hel"))
# print(char.endswith("rld"))
# print(char.endswith("rl "))

# print可以更改间隔符
# print("hello",261,145,3.14,sep=",")
# char = "1234325"
# char2 = "12334abc"
# print(char.isdigit())
# print(char2.isdigit())

# strip --去除两边的空格
# str1 = input("enter your string:")
# print(str1.strip(),261,145)
